<?php


namespace app\app\controller;

//分销
use app\model\AdminDistribution;
use app\util\ReturnCode;
use think\exception\DbException;

class Distribution extends Base
{
    //获取我的分销下级
    public function getMyDistribution(){
        $limit = $this->request->get('size', config('apiadmin.ADMIN_LIST_DEFAULT'));
        $start = $this->request->get('page', 1);
        $model = new AdminDistribution();
        $where = ['pid_1'=>$this->userInfo['uid']];
        $where = $this->addTid($where);
        try {
            $listObj = $model->where($where)->order('create_time DESC')->paginate($limit, false, ['page' => $start])->each(function ($value, $key) {
                $value->wxUserInfo;
            })->toArray();
            return $this->buildSuccess([
                'list' => $listObj['data'],
                'count' => $listObj['total']
            ]);
        } catch (DbException $e) {
        }
        return $this->buildFailed(ReturnCode::FAILED, '获取失败');
    }

}